import React, { useState } from 'react';
import { Text, View } from 'react-native';
import { scaleSizeH, scaleSizeW, setSpText } from '../../util/ScreenUtil.js'
import Icon from "../../assets/fonts/iconfont"
export default function LinkText(props) {
    let { children, number, BoxStyle } = props
    const SELECTED = "#fdad2b"
    const NO_SELECTED = "#e4e4e4"
    BoxStyle = {
        flexDirection: "row",
        width: scaleSizeW(120),
        justifyContent: "space-between"
        , alignItems: "center",
        height: scaleSizeH(20),
        ...BoxStyle
    }
    let numAry = [0, 0, 0, 0, 0];
    function getStartView(number) {
        let Integer = `${number}`.split(".")[0];
        let Decimal = `${number}`.split(".")[1];
        if (Integer >= 9) {
            return <View style={BoxStyle}>
                <Icon name="pingfenxingxing" size={setSpText(20)} color={SELECTED}></Icon>
                <Icon name="pingfenxingxing" size={setSpText(20)} color={SELECTED}></Icon>
                <Icon name="pingfenxingxing" size={setSpText(20)} color={SELECTED}></Icon>
                <Icon name="pingfenxingxing" size={setSpText(20)} color={SELECTED}></Icon>
                <Icon name="pingfenxingxing" size={setSpText(20)} color={SELECTED} ></Icon>
             
            </View>
        } else {
            let newnumber = parseInt(Integer / 2);
            for (let i = 0; i < newnumber; i++) {
                numAry[i] = 1
                if (Decimal >= 5) {
                    numAry[newnumber] = 2
                }
            }
           return renderStart()

        }
    }
    function renderStart() {
        numAry.forEach((v, i) => {
            if (v == 0) {
                numAry[i] = { name: "pingfenxingxing", color: NO_SELECTED }
            } else if (v == 1) {
                numAry[i]= { name: "pingfenxingxing", color:SELECTED }
            }else{
                numAry[i]= { name: "xing3", color:SELECTED }
            }
        })
        return <View style={BoxStyle}>
        <Icon name={numAry[0].name} size={setSpText(20)} color={numAry[0].color}></Icon>
        <Icon name={numAry[1].name} size={setSpText(20)} color={numAry[1].color}></Icon>
        <Icon name={numAry[2].name} size={setSpText(20)} color={numAry[2].color}></Icon>
        <Icon name={numAry[3].name} size={setSpText(20)} color={numAry[3].color}></Icon>
        <Icon name={numAry[4].name} size={setSpText(20)} color={numAry[4].color} ></Icon>
        </View>
    }

    return (
        <View style={BoxStyle}>
            {getStartView(number)}
        </View>
    );
}
